package com.example.project_dish.Dishes;

import static com.example.project_dish.method.return_main;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.project_dish.Capital.CapitalActivity;
import com.example.project_dish.OnDoubleClickListener;
import com.example.project_dish.Order.MyOrderActivity;
import com.example.project_dish.OrderFoodActivity;
import com.example.project_dish.R;
import com.example.project_dish.method;

public class SelectDishActivity extends AppCompatActivity implements View.OnClickListener{
    private TextView icon_text;
    private Button select_dish;
    private Button capital_dish;
    private Button order_dish;
    private ImageView top_image;

    @SuppressLint("WrongViewCast")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_select_dish);

        // 设置背景图片透明度
        top_image = findViewById(R.id.top_image);
        method.setBackground(null,top_image);

        // 设置图标大小
        icon_text = findViewById(R.id.icon_text);
        Drawable drawableLeft = getResources().getDrawable(R.drawable.star);
        drawableLeft.setBounds(0,0,35,35);
        icon_text.setCompoundDrawables(drawableLeft,null,null,null);

        // 设置状态栏透明
        method.status_bar(this);
        if(this.getSupportActionBar() != null){
            this.getActionBar().hide();
        }

        // 设置部分字体颜色
        String icon_text_str = "<font color='#f2cb51'>4.6</font> 月售3000 商家十二分钟内··";
        icon_text.setText(Html.fromHtml(icon_text_str));

        //获取按钮
        select_dish = findViewById(R.id.select_dish);
        select_dish.setOnClickListener(this);
        capital_dish = findViewById(R.id.capital_dish);
        capital_dish.setOnClickListener(this);
        order_dish = findViewById(R.id.order_dish);
        order_dish.setOnClickListener(this);

        //调用双击功能函数
        return_main(top_image);

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.select_dish:
                Intent intent = new Intent(SelectDishActivity.this, SelectDishActivity.class);
                startActivity(intent);
                break;
            case R.id.capital_dish:
                Intent intent1 = new Intent(SelectDishActivity.this, CapitalActivity.class);
                startActivity(intent1);
                break;
            case R.id.order_dish:
                Intent intent2 = new Intent(SelectDishActivity.this, MyOrderActivity.class);
                startActivity(intent2);
                break;
        }
    }
}